import {
  ComponentFactory,
  ComponentFactoryResolver,
  Directive,
  ElementRef, Host, Input,
  Optional,
  Renderer2,
  ViewContainerRef
} from '@angular/core';

import { ApesNoAnimationDirective, ApesTSType } from '@shared/apes/core';
import { ApesPopoverComponent } from "@shared/apes/popover/apes-popover.component";
import { ApesToolTipBaseDirective } from '@shared/apes/tooltip';
import { ApesToolTipTrigger } from "@shared/apes/tooltip/apes-tooltip.definitions";


@Directive({
  selector: '[apes-popover]',
  exportAs: 'apesPopover',
  host: {
    '[class.apes-popover-open]': 'isToolTipComponentVisible'
  }
})
export class ApesPopoverDirective extends ApesToolTipBaseDirective {
  @Input('apesPopoverTitle') specificTitle: ApesTSType;
  @Input('apesPopoverContent') specificContent: ApesTSType;
  @Input('apes-popover') directiveNameTitle: ApesTSType | null;
  @Input('apesPopoverTrigger') specificTrigger: ApesToolTipTrigger;
  @Input('apesPopoverPlacement') specificPlacement: string;

  componentFactory: ComponentFactory<ApesPopoverComponent> = this.resolver.resolveComponentFactory(ApesPopoverComponent);

  constructor(
    elementRef: ElementRef,
    hostView: ViewContainerRef,
    resolver: ComponentFactoryResolver,
    renderer: Renderer2,
    @Optional() tooltip: ApesPopoverComponent,
    @Host() @Optional() public noAnimation?: ApesNoAnimationDirective
  ) {
    super(elementRef, hostView, resolver, renderer, tooltip, noAnimation);
  }
}
